<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
session::need_member();
$size=30;
if(empty($_GET["pagesid"]))
{
	$Pages_id=1;
	$offset=0;
}
else
{
	$Pages_id=intval($_GET["pagesid"]);
	$offset=($Pages_id-1)*$size;
}
if(session::is_manager()==TRUE)
{
	
	$table='orders,userinfo';
	$select='orders.userid,orderid,orders.money,refund,timeorder,site,orders.check,username';
	if(!empty($_GET["userid"]))
	{
		$UserId=$_GET["userid"];
		$condition=array(
		'userinfo.userid=orders.userid',
		"orders.userid=$UserId"
		);
	}
	else 
	{
		$condition=array(
		'userinfo.userid=orders.userid');
	}
	
	$order='order by id desc';
	$countpages=database::count('orders', '1=1');
}
else if(session::is_member())
{
	$table='orders';
	$UserId=session::getuserid();
	$select='orderid,money,refund,timeorder,site,orders.check';
	$condition=array(
	'userid' => $UserId,
	);
	$order='order by orderid desc';
	$countpages=database::count('orders', $condition);
	
}
$GetOrderHistory=database::LimitQuery($table,array(
'select' => $select,
'condition' => $condition,
'order' => $order,
'offset' =>$offset,
'size' => $size
));
$pagesnum=ceil($countpages/$size);
require_once 'html/orderhistory.php';
?>